package com.test.jmx.jobss;

import java.util.List;
import java.util.Map;

import org.jboss.ejb3.annotation.Management;
import org.jboss.ejb3.annotation.Service;

@Management(ConfigMBean.class)
@Service(objectName = "com.test.jmx.jobss:service=Config")
public class Config implements ConfigMBean {

	private ValueHolder vh = ValueHolder.getInstance();

	@Override
	public int getCount() {
		return vh.getCount();
	}

	@Override
	public void setCount(int count) {
		vh.setCount(count);
		System.out.println("Set count to " + count);
	}

	@Override
	public void startService() {
		System.out.println("Start config service...");
	}

	@Override
	public void showCount() {
		System.out.println("Count is " + vh.getCount());
	}

	@Override
	public void addItem(String key, String value) {
		vh.addItem(key, value);
		System.out.println("Added an item:<" + key + "," + value + ">.");
	}

	@Override
	public void showItems() {
		vh.showItems();
	}

	@Override
	public List<String> getList() {
		return vh.getList();
	}

	@Override
	public Map<String, String> getMap() {
		return vh.getMapContainer();
	}

	@Override
	public void setList(List<String> list) {
		vh.setList(list);
	}

	@Override
	public void setMap(Map<String, String> map) {
	}

}
